Macromedia Flex Article

Extending Design Patterns into RIA


Table of Contents

  1. Introduction
  2. Rich Internet Application Design
  3. Patterns in a Rich Internet Application Architecture
  4. Client Component to Server Communication
  5. There Is Always More

Client Component to Server Communication

The design for client component to server communications must take into account the smaller and more granular components that comprise the interface, as well as the ability for components to contain other components and retain their independence. The requirements of the UI components include:

  • Central control of component functionality
  • Central control for message reception
  • Central control for service communication
  • Separate code to control the interface logic and the event management

This design uses four classes over which the user interface sits. The following diagram demonstrates:

Client component to server communication requires four class types

Figure 6. Client component to server communication requires four class types.

The responsibilities for each class are as follows:

  • The user interface is where the controls (calendar, data grids, check boxes, colors, etc.) reside.
  • The view logic contains the code for manipulating the user interface, mapping data to fields, drawing data out and so on.
  • The local data model represents the components that hold the data for the application.
  • The controller and mediator are often implemented as one component.

    • The controller is responsible for controlling all processes for the user interface. It determines how to handle events from the remote server or from the user interface.
    • The mediator is responsible for communicating externally from the component to the remote service. The mediator is also responsible for containing the methods that can be called back to from the remote service.

By designing a user interface in this way, the UI components remain independent, regardless of how you place them in the interface. By providing a common abstract interface for individual components, the mediator allows a UI component to behave independently or as part of a larger interface component. The following diagram describes the client architecture:

The client architecture

Figure 7. The client architecture

Take the bank application as an example. It includes an interface component that submits a customer service request to the bank. The service broker requests a handle to the remote service from the interface component so that it can invoke the appropriate methods. The interface consists of a variety of controls and a button that triggers an event. The view logic for the interface controller can capture this event. When the event is called, it triggers the controller and instructs the view logic to build a local data model for the transaction. Once the app populates the data model, the controller tells the mediator to submit a customer service request and pass the collected data. The mediator talks to the service broker to request the appropriate service and passes it a handle to itself. Once the mediator receives the information from the service broker it invokes a message that spawns the appropriate request. After the service finishes running on the server, it passes the responding message to the client. The bridge routes this responding message to the mediator, which determines which method to call on the controller and then calls that message so that it affects the interface appropriately.